package com.vertx.user.rest;

import com.vertx.core.annotation.inject.Autowired;
import com.vertx.user.store.UserService;
import com.vertx.web.annotation.RequestMethod;
import com.vertx.web.annotation.Rest;
import com.vertx.web.annotation.RestApi;
import com.vertx.web.annotation.RestRouter;
import io.vertx.core.Vertx;
import io.vertx.core.json.Json;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.RoutingContext;

/**
 * 描述:
 * 创建人:hzw
 * 创建时间: 2018/4/26 11:09
 **/
@Rest
@RestRouter(path = "/user")
public class UserRest {

    @Autowired
    private UserService userService;

    @RestApi(path = "/getUser",method = RequestMethod.GET)
    public void getUser(RoutingContext routingContext, Vertx vertx){
        JsonObject jsonObject=new JsonObject();
        JsonObject _json = new JsonObject();
        userService.test(_json,rp->{
            if(rp.succeeded()){
                System.out.println(rp.result()+">>>");
                routingContext.response().end(Json.encode(rp.result()));
            }else{
                routingContext.response().end("no");
            }
        });

    }
}
